package com.stockz.ui.swing.watchlist.widget;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.stockz.ui.swing.core.MainFrame;
import com.stockz.ui.swing.core.menu.NewMenu;
import com.stockz.ui.swing.watchlist.WatchListView;
import com.stockz.ui.swing.widget.JMenuItem;

@Component
public class WatchListViewMenuItem extends JMenuItem implements ActionListener,
		InitializingBean {
	private static final long serialVersionUID = 845682431749254398L;

	@Autowired
	private NewMenu newMenu;
	
	public WatchListViewMenuItem() {
		super("WatchLists",KeyEvent.VK_W,ActionEvent.ALT_MASK,"scanner.png");
		addActionListener(this);
	}
	
	@Override
	public void afterPropertiesSet() throws Exception {
		newMenu.add(this);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		WatchListView watchListView = new WatchListView();
		MainFrame.getInstance().add(watchListView);
	}

}
